﻿using JsonTest;
using System.Text.Json;

try
{
    var o = new E_Complex();
    //var o = new E_Simple();
    //DateTime t = DateTime.Now;
    //o.D.C.Add(new E_Simple(), "added");

    //o.D.S.Add("03", new E_Simple() { P_Int = 6 });
    //o.C.Collect.Add(new E_Simple() { P_Int = 5 });

    var option = new JsonSerializerOptions(JsonSerializerDefaults.General)
    {
        WriteIndented = true
    };
    option.Converters.Add(new JsonDatetimeConverter());
    option.Converters.Add(new JsonColorConverter());
    option.Converters.Add(JsonDictConverter.Gen(o.D.C));

    Console.WriteLine(o.D.C.GetType().FullName);

    var str = JsonSerializer.Serialize(o, typeof(E_Complex), option);
    Console.Write(str);
    Console.WriteLine();

    var n = JsonSerializer.Deserialize<E_Complex>(str, option);
}
catch (Exception e)
{
    Console.WriteLine(e.Message);
    Console.WriteLine(e.StackTrace);
}
Console.ReadLine();